#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int main()
{
	int n = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		bool f = 0;
		if (i % 7 == 0) {
			cout << i << endl;
			continue;
		}
		int x = i;
		while (x) {
			if (x % 10 == 7) {
				f = 1;
				break;
			}
			x /= 10;
		}
		if (f) {
			cout << i << endl;
		}
	}
	return 0;
}